using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;

using System.Xml;
using System.ComponentModel;


namespace CUtil
{
	

	//[System.Xml.Serialization.XmlRootAttribute("TradeCondition", Namespace="", IsNullable=false)]
	[System.Xml.Serialization.XmlRoot()]
	public class IndicatorComposed : XMLSerializable, IIndicatorComposed //this does not work !! :ITradeCondition
	{

		#region private fields

        private bool isGlobal;
        private IList<IndicatorElement> indicatorElements;

    
		#endregion

		#region constructor, dispose

		public IndicatorComposed()
		{
            indicatorElements = new List<IndicatorElement>();
			this.iD = "MyNewIndicator";
			
		}
		#endregion

        #region static members


        #endregion

        #region public properties


        [System.Xml.Serialization.XmlIgnoreAttribute()]
        public new string Path
        {
            get
            {
                return this.path ;
            }
            set
            {
                this.path = value;
              
            }
        }


        [System.Xml.Serialization.XmlIgnoreAttribute()]
		public new string FileName
		{
			get
			{
				return this.iD + ".xml";
			}
			set
			{
				string str = value;
				string[] arrStr = str.Split(new Char[] {'\\'},100);
				//string MyAssemblyName="Framework.PropertyView." + MystrArr[MystrArr.GetLength(0)-1] + ".dll";
				string name = arrStr[arrStr.GetLength(0)-1];
			}
		}

		[System.Xml.Serialization.XmlIgnoreAttribute()]
		public IList<IndicatorElement> IndicatorElements 
		{
			get
			{
				return indicatorElements;
			}
			set
			{
				indicatorElements = value;
			}
		}
        public override string ToString()
        {
            if(! string.IsNullOrEmpty(this.iD))
                return this.iD.ToString();
            else
              return base.ToString();
        }

       
		[Browsable(false)]
		public IndicatorElement[] ArrIndicatorElements
		{
			get
			{
				try
				{
                    System.Collections.Generic.List<IndicatorElement> arrL = this.indicatorElements as List<IndicatorElement>;

                    if (arrL != null && arrL.Count > 0)
                        return (IndicatorElement[])arrL.ToArray();
                    else
                        return null;

					
				}
				catch (Exception exc)
				{
					Debug.Assert(false,"Portfolio - " + "Error creating ItemTypeArray ",exc.Message);
				}
				return null;
			}
			set
			{
                this.indicatorElements = new List<IndicatorElement>();
                for (int i = 0; i < value.Length; i++)
                {
                    IndicatorElement s = value[i] as IndicatorElement;
                    indicatorElements.Add(s);


                }
			}
		}

        public bool IsGlobal
        {
            get
            {
                return isGlobal;
            }
            set
            {
                isGlobal = value;
            }
        }
		
		#endregion

	}
}
